﻿using System;
using System.Reflection;
using Shell.PocoDot;

namespace Shell.DomainDot
{
    public class WithAllInjector_1 : WithAllInjector
    {
        private static Type typeSupported;

        static WithAllInjector_1()
        {
            typeSupported = typeof(WithAll<,>);
        }

        protected override Type TargetDomainType
        {
            get { return typeSupported; }
        }

        protected override Type GetPocoType(PropertyInfo domainSegment)
        {
            var t = domainSegment.PropertyType;
            if (t.IsGenericType && t.GetGenericTypeDefinition() == this.TargetDomainType)
            {
                return domainSegment.PropertyType.GetGenericArguments()[1];
            }
            return null;
        }
    }
}
